﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LoginCentralizado;
using System.Web.Security;

namespace Prueba
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                AutoLogin login = new AutoLogin("fjtt63qw@psk35", "t@lPsk", "MD5", 1, "@1B2c3D4e5F6g7H8", 128);
                login.Loguear();
            }
        }

        protected void btnLetsGoBitch_Click(object sender, EventArgs e)
        {
            AutoLogin login = new AutoLogin("fjtt63qw@psk35", "t@lPsk", "MD5", 1, "@1B2c3D4e5F6g7H8", 128);
            login.Redirigir(txtUrl.Text);
        }

        protected void btnLoguear_Click(object sender, EventArgs e)
        {
            FormsAuthentication.Initialize();
            FormsAuthenticationTicket fat = new FormsAuthenticationTicket(1, txtUsuario.Text, DateTime.Now, DateTime.Now.AddMinutes(30), false, @"", FormsAuthentication.FormsCookiePath);

            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(fat)));
        }

        protected void btnDesloguear_Click(object sender, EventArgs e)
        {
            FormsAuthentication.SignOut();
        }
    }
}